Skip to content

fix: update oasdiff to v1.14.0 and migrate from oasdiff/kin-openapi to getkin/kin-openapi#1228

Merged
andreaangiolillo merged 9 commits into
mainfrom
copilot/update-logic-for-breaking-changes
Apr 15, 2026
Merged

fix: update oasdiff to v1.14.0 and migrate from oasdiff/kin-openapi to getkin/kin-openapi#1228
andreaangiolillo merged 9 commits into
mainfrom
copilot/update-logic-for-breaking-changes

Conversation

Copilot AI commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Fixes the build failures caused by upgrading github.com/oasdiff/oasdiff from v1.13.1 to v1.14.0 (see dependabot PR #1208).

oasdiff v1.14.0 introduced two breaking changes:

  1. Dependency migration: Migrated from its own github.com/oasdiff/kin-openapi fork to the upstream github.com/getkin/kin-openapi, causing type incompatibilities across ~55 Go files in tools/cli and 6 files in tools/mcp-server.
  2. Message format change: Changed GetUncolorizedText() output from single-quoted values ('value') to backtick-quoted values (`value`), and added the HTTP status code as an extra argument to several response-related message templates.

Changes:

  • tools/cli/go.mod: Replace github.com/oasdiff/kin-openapi v0.136.10 with github.com/getkin/kin-openapi v0.135.0 (the version used by oasdiff v1.14.0) and bump oasdiff to v1.14.0
  • tools/mcp-server/go.mod: Replace github.com/oasdiff/kin-openapi v0.136.10 with github.com/getkin/kin-openapi v0.135.0 as a direct dependency
  • ~61 Go source/test files: Replace all imports of github.com/oasdiff/kin-openapi/openapi3 with github.com/getkin/kin-openapi/openapi3 and apply gci import formatting across both tools/cli and tools/mcp-server
  • tools/cli/go.sum and tools/mcp-server/go.sum: Updated via go mod tidy
  • .gitignore: Added tools/go.work.sum to prevent the auto-generated workspace checksum file from being accidentally committed
  • squash.go: Updated identifierRegex from '([^']*)' to `([^`]*)` to match backtick-quoted values; replaced the "" placeholder with \x01 (ASCII SOH) to avoid false regex matches during the two-phase text construction (phase 1 marks substitutions with \x01<value>\x01; phase 2 converts \x01' for the final output format)
  • enum.go: Updated expectedNumberOfValues for response-property-enum-value-added/removed and response-write-only-property-enum-value-added (2→3), and response-mediatype-enum-value-removed (1→2, squashIdx 0→1) to handle the new status code and newly-quoted media type arguments; wrapped long comment examples across two lines to satisfy the lll linter (150-character limit)
  • field.go: Added the new expectedNumberOfValues parameter to squashFieldChanged — set to 1 for request handlers (which have a single backtick-quoted value: the property name) and 2 for response handlers (which now include the HTTP status code as a second backtick-quoted value in oasdiff v1.14.0)
  • Unit tests (squash_test.go, enum_test.go, field_test.go): Updated input texts to use backtick format; expected outputs continue to use single-quote format (squash output) with status codes now included; added //nolint:lll //Test string annotations to test string literals that inherently exceed the 150-character line limit, matching the existing pattern used elsewhere in those files
  • E2e test data: Regenerated all 5 test data directories (new-api-version, same-api-version, new-api-preview-version, new-upcoming-version, rename-api-version) using the updated CLI binary with --run-date 2025-06-15, matching the fixed date used by the e2e test

Jira ticket: CLOUDP-#

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works

Changes to Spectral

  • I have read the README file for Spectral Updates

Further comments

Validation:

  • go build ./... ✅ (both tools/cli and tools/mcp-server)
  • go test ./internal/... ✅ (all 25 test packages pass)
  • gci import formatting applied to all changed Go files ✅
  • lll lint violations resolved in enum.go, enum_test.go, and field_test.go
  • E2e test data regenerated with updated CLI binary and correct --run-date 2025-06-15 flag ✅
  • TestChangelog/Generate_Changelog_with_Upcoming_API_Version e2e test passes ✅

…o getkin/kin-openapi

Agent-Logs-Url: https://github.com/mongodb/openapi/sessions/c0e1cb22-e1cc-4ad1-a06b-e58f8deb479a

Co-authored-by: andreaangiolillo <5663078+andreaangiolillo@users.noreply.github.com>
…oasdiff v1.14.0 compatibility

Agent-Logs-Url: https://github.com/mongodb/openapi/sessions/c0e1cb22-e1cc-4ad1-a06b-e58f8deb479a

Co-authored-by: andreaangiolillo <5663078+andreaangiolillo@users.noreply.github.com>
Comment thread tools/go.work.sum Outdated
@@ -0,0 +1,127 @@
cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY=

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Why do we need this file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was accidentally generated when running go mod tidy in a workspace context. It's not needed — removed in 825e855.

Agent-Logs-Url: https://github.com/mongodb/openapi/sessions/5fced335-cabe-4abd-8ea4-91b700fec381

Co-authored-by: andreaangiolillo <5663078+andreaangiolillo@users.noreply.github.com>
Comment thread tools/cli/internal/apiversion/version.go
Copilot AI and others added 2 commits April 15, 2026 10:01
Agent-Logs-Url: https://github.com/mongodb/openapi/sessions/6b19d61d-16e1-427c-90be-23ea97d85a1f

Co-authored-by: andreaangiolillo <5663078+andreaangiolillo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/mongodb/openapi/sessions/6b19d61d-16e1-427c-90be-23ea97d85a1f

Co-authored-by: andreaangiolillo <5663078+andreaangiolillo@users.noreply.github.com>
Comment thread tools/mcp-server/go.mod Outdated
Agent-Logs-Url: https://github.com/mongodb/openapi/sessions/44ea7958-f26f-4959-a88e-d74966dfc9bc

Co-authored-by: andreaangiolillo <5663078+andreaangiolillo@users.noreply.github.com>
Comment thread tools/cli/internal/apiversion/version.go
…rmat changes

Agent-Logs-Url: https://github.com/mongodb/openapi/sessions/2dad8bfe-ecbd-467c-a9fc-186f6c06d9f3

Co-authored-by: andreaangiolillo <5663078+andreaangiolillo@users.noreply.github.com>
Comment thread tools/cli/internal/changelog/outputfilter/enum.go
…incorrectly added in previous commit

Agent-Logs-Url: https://github.com/mongodb/openapi/sessions/521d59a0-16c2-4643-826c-cbe80bdca3f9

Co-authored-by: andreaangiolillo <5663078+andreaangiolillo@users.noreply.github.com>
{
ID: "response-write-only-property-enum-value-added",
Text: "added the new 'DUBLIN_IRL' enum value to the '/items/dataProcessRegion/region' response write-only property",
Text: "added the new `DUBLIN_IRL` enum value to the `/items/dataProcessRegion/region` response write-only property for the response status `200`",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cd3d20f. The lll linter was flagging 8 lines exceeding 150 characters:

  • enum.go lines 9, 22, 48: wrapped long comment examples across two lines
  • enum_test.go lines 22, 29, 185, 241 and field_test.go line 192: added //nolint:lll //Test string annotations, matching the existing pattern already used in those files

…test.go

Agent-Logs-Url: https://github.com/mongodb/openapi/sessions/33781a4c-0055-4b2d-83fe-351d96eea656

Co-authored-by: andreaangiolillo <5663078+andreaangiolillo@users.noreply.github.com>
Comment on lines +18 to +20
// squashPlaceholder is used internally during squash text construction to mark substituted values.
// It must not appear in any oasdiff message text. The final text replaces this with a single quote.
squashPlaceholder = "\x01"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Why did you introduced this placeholder? what are the advantages and disadvantages of using it? why this was not defined before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The placeholder (\x01, ASCII SOH) was introduced because replaceOnlyFirstOccurrence needs two-phase text construction:

  1. Phase 1: It replaces each backtick-quoted value in the template with \x01<value>\x01 (e.g. `DUBLIN_IRL`\x01DUBLIN_IRL\x01)
  2. Phase 2: After all values are substituted, a final strings.ReplaceAll converts every \x01' to produce the output format (e.g. 'DUBLIN_IRL')

Why not use "" (empty string)?
Before oasdiff v1.14.0, the input messages used single-quoted values (e.g. 'DUBLIN_IRL'). The old placeholder was "", which simply wrapped the replacement value in empty strings — harmless because single quotes couldn't appear inside another single-quoted value.

With v1.14.0, the input now uses backticks (e.g. `DUBLIN_IRL`). If we still used "" as the placeholder during Phase 1, any replacement value that itself contains a backtick (e.g. a path like `/items/region`) would accidentally match the identifierRegex again in subsequent iterations of ReplaceAllStringFunc, causing double-substitution.

\x01 (SOH) is safe because it's a control character that oasdiff never includes in its message text, so it can't create a false regex match during Phase 1.

@andreaangiolillo andreaangiolillo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andreaangiolillo andreaangiolillo marked this pull request as ready for review April 15, 2026 13:13
@andreaangiolillo andreaangiolillo requested a review from a team as a code owner April 15, 2026 13:13
@andreaangiolillo andreaangiolillo enabled auto-merge (squash) April 15, 2026 13:14
@andreaangiolillo andreaangiolillo merged commit deff19d into main Apr 15, 2026
17 checks passed
@andreaangiolillo andreaangiolillo deleted the copilot/update-logic-for-breaking-changes branch April 15, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants